﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;

namespace SpaceHero.Screens
{
    class ScreenManager
    {
        LogoScreen logoScreen;
        MainMenuScreen mainMenuScreen;
        GameScreen gameScreen;

        KeyboardState keyState;
        KeyboardState oldKeyState;

        public ScreenManager(GraphicsDeviceManager graphics)
        {
            logoScreen = new LogoScreen();
            mainMenuScreen = new MainMenuScreen(graphics);
        }
        
        public void LoadContent(StateManager.GameStates state, ContentManager Content)
        {
            logoScreen.LoadContent(Content);
            mainMenuScreen.LoadContent(Content);
        }

        public void Update(StateManager.GameStates state, GameTime gameTime, StateManager stateManager, KeyboardState keyState)
        {
            this.keyState = keyState;

            switch (state)
            {
                case StateManager.GameStates.LogoScreen:
                    {
                        logoScreen.Update(gameTime, stateManager, keyState, oldKeyState);
                        break;
                    }
                case StateManager.GameStates.MainMenu:
                    {
                        mainMenuScreen.Update(gameTime, stateManager, keyState, oldKeyState);
                        break;
                    }
                case StateManager.GameStates.GamePlay:
                    {
                        break;
                    }
                case StateManager.GameStates.Options:
                    {
                        break;
                    }
                case StateManager.GameStates.Exit:
                    {
                        break;
                    }
                default:
                    {
                        break;
                    }
            }

            oldKeyState = keyState;
        }

        public void Draw(StateManager.GameStates state, SpriteBatch spriteBatch, GraphicsDeviceManager graphics)
        {
            switch (state)
            {
                case StateManager.GameStates.LogoScreen:
                    {
                        logoScreen.Draw(graphics, spriteBatch);
                        break;
                    }
                case StateManager.GameStates.MainMenu:
                    {
                        mainMenuScreen.Draw(graphics, spriteBatch);
                        break;
                    }
                case StateManager.GameStates.Options:
                    {
                        break;
                    }
                case StateManager.GameStates.Exit:
                    {
                        break;
                    }
                case StateManager.GameStates.GamePlay:
                    {
                        break;
                    }
                default:
                    {
                        graphics.GraphicsDevice.Clear(Color.Red);
                        break;
                    }
            }
        }
    }
}